#ifndef _HASHMAPLIB_H_
#define _HASHMAPLIB_H_

#define DEBUG 

/* hashmap node struct */
struct cel_hashmap_node_struct {
	char *key;
	unsigned int hash;
	union {
		void *ptr;
		int num;
	} value;
	struct cel_hashmap_node_struct *next;
};
typedef struct cel_hashmap_node_struct cel_hashmap_node_t;

/* cel hashmap entry */
typedef struct {
	cel_hashmap_node_t **table;
	unsigned int length;
	unsigned int size;
	unsigned int threshold;
	float factor;
} cel_hashmap_t;

/* cel hashmap release callback function pointer */
typedef void (* cel_hashmap_rcb_fn_t) (cel_hashmap_node_t *);

#define cel_hashmap_size(map)		(map->size)
#define cel_hashmap_length(map)		(map->length)
#define cel_hashmap_factor(map)		(map->factor)
#define cel_hashmap_threshold(map)	(map->threshold)

#define new_cel_hashmap()	new_cel_hashmap_opacity(16, 0.75);
cel_hashmap_t *new_cel_hash_map_opacity(int opacity, float factor);
void free_cel_hashmap(cel_hashmap_t **hash, cel_hashmap_rcb_fn_t relfunc);
void *cel_hashmap_put(cel_hashmap_t *hash, char *key, void *value);
void *cel_hashmap_remove(cel_hashmap_t *hash, char *key, cel_hashmap_rcb_fn_t rfunc);
void *cel_hashmap_get(cel_hashmap_t *hash, char *key);
int cel_hashmap_exists(cel_hashmap_t *hash, char *key);
void *cel_hashmap_set(cel_hashmap_t *hash, char *key, void *value);


#endif //_HASHMAPLIB_H_
